﻿using System;
using Grundy.Common;
using Grundy.Entity;
using Grundy.Message;

namespace Grundy.Licensing.Server
{
    public class LicenseNotFoundException : Exception
    {
        public License License { get; private set; }
        public FeatureIdentificationKey FeatureIdentificationKey { get; protected set; }

        public LicenseNotFoundException(FeatureIdentificationKey featureIdentificationKey)
        {
            FeatureIdentificationKey = featureIdentificationKey;
        }

        public override string Message
        {
            get
            {
                var k = FeatureIdentificationKey;
                return "Could not find a matching feature. {{ Feature Id: {0}, Feature: {1}, License Id: {2}, License: {3}, Product Id: {4}, Product: {5} }}"
                    .FormatWith(k.FeatureId, k.FeatureName, k.LicenseEntitlementId, k.LicenseName, k.ProductId, k.ProductName);
            }
        }
    }
}